﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

class OPT
{
    private static Dictionary<string, string> list = new Dictionary<string, string>();

    public static void ReadOpt(string filename)
    {
        try
        {
            Byte[] Xor = new Byte[] {
                         0x55, 0x99, 0x99, 0xCC, 0x11, 0xAA, 0xBB, 0x66, 0x55, 0x88, 0x44, 0xDD, 0x66, 0xEE, 0xFF, 0x88, 
                         0x22, 0x22, 0xDD, 0x55, 0xEE, 0xDD, 0x33, 0xFF, 0xDD, 0xAA, 0x11, 0x44, 0x00, 0x99, 0xBB, 0x66, 
                         0xDD, 0x33, 0x77, 0x33, 0xFF, 0x55, 0xAA, 0x33, 0x99, 0x00, 0x33, 0x77, 0xFF, 0xBB, 0x22, 0xFF, 
                         0xCC, 0x66, 0x44, 0xFF, 0xDD, 0x99, 0x66, 0xFF, 0x22, 0xEE, 0x99, 0x77, 0xAA, 0x55, 0xBB, 0xAA, 
                         0xBB, 0xDD, 0x77, 0x55, 0x22, 0x77, 0x33, 0x33, 0x66, 0xEE, 0x66, 0xBB, 0x11, 0xFF, 0x33, 0x11, 
                         0x99, 0x99, 0x44, 0x44, 0xEE, 0x00, 0xEE, 0x55, 0x66, 0xDD, 0x11, 0xBB, 0x44, 0x44, 0x99, 0x55, 
                         0x77, 0x44, 0x55, 0x11, 0x77, 0x77, 0x99, 0xFF, 0x55, 0xDD, 0x77, 0x77, 0xBB, 0x00, 0x44, 0x77, 
                         0xDD, 0x77, 0x77, 0x55, 0x22, 0x66, 0xCC, 0xCC, 0xDD, 0x44, 0x55, 0x11, 0xEE, 0x88, 0x99, 0x00, 
                         0x66, 0x44, 0xBB, 0xAA, 0xCC, 0x88, 0x00, 0xFF, 0xAA, 0xCC, 0x11, 0xEE, 0xCC, 0x11, 0x77, 0xAA, 
                         0x11, 0xDD, 0x77, 0x11, 0x55, 0xFF, 0x33, 0xCC, 0xEE, 0x00, 0x00, 0x88, 0x55, 0x77, 0xDD, 0x44, 
                         0xFF, 0xAA, 0x44, 0xFF, 0x11, 0xFF, 0x88, 0xCC, 0xDD, 0x55, 0xEE, 0xFF, 0x11, 0x77, 0xFF, 0x11, 
                         0x99, 0x77, 0xFF, 0xAA, 0x88, 0x11, 0x66, 0xCC, 0x11, 0xEE, 0xAA, 0x33, 0x99, 0x55, 0x77, 0x99, 
                         0x99, 0x33, 0xAA, 0x00, 0x44, 0x00, 0x66, 0xEE, 0x55, 0x55, 0x88, 0xAA, 0xAA, 0x77, 0xFF, 0x66, 
                         0xEE, 0x11, 0x99, 0x00, 0x77, 0xFF, 0x77, 0x66, 0xBB, 0x88, 0x00, 0x00, 0x77, 0x77, 0x99, 0x77, 
                         0xAA, 0xAA, 0x77, 0xFF, 0x44, 0x00, 0xBB, 0xEE, 0x77, 0x99, 0xBB, 0x11, 0x66, 0x44, 0x99, 0x00, 
                         0x44, 0x88, 0x00, 0x44, 0x22, 0xEE, 0x99, 0x22, 0x33, 0xDD, 0xBB, 0x11, 0xFF, 0x11, 0x77, 0x88, 
                         0x88, 0xCC, 0x77, 0xBB, 0xEE, 0x44, 0xAA, 0x44, 0xAA, 0xEE, 0x11, 0x44, 0x11, 0x44, 0xFF, 0xAA, 
                         0x44, 0x99, 0xFF, 0x55, 0x77, 0x33, 0xEE, 0x99, 0xFF, 0x99, 0x66, 0x66, 0xEE, 0x88, 0x33, 0x44, 
                         0xBB, 0x77, 0x33, 0x66, 0x11, 0xFF, 0x66, 0x99, 0x55, 0x00, 0x44, 0x33, 0xCC, 0xBB, 0x55, 0x99, 
                         0x33, 0x00, 0xFF, 0x55, 0x55, 0x22, 0x99, 0x22, 0x66, 0x88, 0xBB, 0xFF, 0x44, 0x00, 0xFF, 0x22, 
                         0x88, 0x55, 0x66, 0xFF, 0xDD, 0x77, 0x00, 0x55, 0xEE, 0xBB, 0xFF, 0xFF, 0x44, 0xEE, 0xCC, 0x99, 
                         0x88, 0x99, 0xCC, 0x44, 0xAA, 0xFF, 0xBB, 0x77, 0xFF, 0x66, 0x66, 0xEE, 0xFF, 0xEE, 0xDD, 0xCC, 
                         0x66, 0x55, 0xBB, 0x77, 0xFF, 0xFF, 0xCC, 0x11, 0xCC, 0xCC, 0xBB, 0x99, 0x99, 0x00, 0x77, 0x00, 
                         0x99, 0x22, 0x00, 0x22, 0x44, 0x00, 0x99, 0x00, 0x00, 0x11, 0xFF, 0x22, 0xCC, 0x66, 0x11, 0xBB, 
                         0xBB, 0x11, 0xCC, 0x00, 0x66, 0xDD, 0xCC, 0x55, 0x55, 0xFF, 0x55, 0x00, 0x77, 0x77, 0x99, 0x88,
                         0xDD, 0x66, 0x44, 0x00, 0x33, 0x88, 0x44, 0x66, 0xFF, 0x55, 0x33, 0xCC, 0xCC, 0xDD, 0xDD, 0x66, 
                         0xFF, 0x88, 0x33, 0x88, 0x00, 0x55, 0x22, 0xAA, 0x00, 0x22, 0x66, 0x66, 0xFF, 0x77, 0x33, 0x88, 
                         0xAA, 0x22, 0x55, 0xFF, 0x44, 0xDD, 0xEE, 0x00, 0x33, 0xDD, 0xCC, 0xDD, 0xBB, 0x88, 0x33, 0x66, 
                         0x77, 0x55, 0xCC, 0x11, 0xCC, 0xBB, 0x11, 0x99, 0x33, 0x00, 0x88, 0xAA, 0xEE, 0x55, 0x99, 0xAA, 
                         0x77, 0x33, 0xCC, 0xFF, 0x66, 0x22, 0xAA, 0x88, 0x22, 0x77, 0x33, 0x55, 0xAA, 0x99, 0x66, 0x44, 
                         0xBB, 0x44, 0x00, 0xBB, 0x88, 0x44, 0xCC, 0x99, 0x55, 0x55, 0x77, 0xEE, 0x33, 0x44, 0xEE, 0x66, 
                         0xAA, 0x44, 0x44, 0x00, 0x88, 0xCC, 0xBB, 0x66, 0x44, 0x00, 0x44, 0x55, 0x55, 0x88, 0x88, 0x88
            };

            Byte[] file_data = File.ReadAllBytes(filename);
            Byte xors = 0;

            for (int i = 0; i < file_data.Length; i++)
            {
                file_data[i] ^= Xor[xors];
                xors++;
            }

            string decrypted_opt = Encoding.ASCII.GetString(file_data);
            string[] first_string;
            string[] second_string;
            foreach (string line in decrypted_opt.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None))
            {
                first_string = line.Split(':');
                second_string = first_string[0].Split(' ');

                switch (second_string[0])
                {
                    case "S":
                        if (list.ContainsKey(second_string[1]))
                        {
                            list.Remove(second_string[1]);
                            list.Add(second_string[1], first_string[1]);
                        }
                        else
                        {
                            list.Add(second_string[1], first_string[1]);
                        }
                        break;

                    case "F":
                        if (list.ContainsKey(second_string[1]))
                        {
                            list.Remove(second_string[1]);
                            list.Add(float.Parse(second_string[1]).ToString(), float.Parse(first_string[1]).ToString());
                        }
                        else
                        {
                            list.Add(float.Parse(second_string[1]).ToString(), float.Parse(first_string[1]).ToString());
                        }
                        break;

                    case "N":
                        if (list.ContainsKey(second_string[1]))
                        {
                            list.Remove(second_string[1]);
                            list.Add(int.Parse(second_string[1]).ToString(), int.Parse(first_string[1]).ToString());
                        }
                        else
                        {
                            list.Add(int.Parse(second_string[1]).ToString(), int.Parse(first_string[1]).ToString());
                        }
                        break;
                }
            }
        }
        catch { }
    }

    public static void SetString(string key, string value)
    {
        if (list.ContainsKey(key))
        {
            list.Remove(key);
            list.Add(key, value);
        }
        else
        {
            list.Add(key, value);
        }
    }

    public static void SetString(string key, int value)
    {
        if (list.ContainsKey(key))
        {
            list.Remove(key);
            list.Add(key, value.ToString());
        }
        else
        {
            list.Add(key, value.ToString());
        }
    }

    public static void SetString(string key, float value)
    {
        if (list.ContainsKey(key))
        {
            list.Remove(key);
            list.Add(key, value.ToString());
        }
        else
        {
            list.Add(key, value.ToString());
        }
    }

    public static string GetString(string key)
    {
        string value;
        list.TryGetValue(key, out value);
        return value;
    }

}
